Skip to content

ARIA heading role: aria-level is required #39482

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

js-choi
Copy link
Contributor

@js-choi js-choi commented May 12, 2025

Description

Changes the description of the ARIA heading role’s aria-level attribute to state that it is required, rather than stating that it defaults to 2.

Motivation

See the ARIA 1.3 specification for heading:

To ensure elements with a role of heading are organized into a logical outline, authors MUST use the aria-level attribute to indicate the proper nesting level.

Additional details

The MDN page on the aria-level role already states that the heading role is required.

I’m not sure where the “If no level is present, a value of 2 is the default” claim comes from.

Related issues and pull requests

None.

See the [ARIA 1.3 specification for heading](https://www.w3.org/TR/wai-aria-1.3/#heading):

> To ensure elements with a role of heading are organized into a logical outline, authors MUST use the aria-level attribute to indicate the proper nesting level.
@js-choi js-choi requested a review from a team as a code owner May 12, 2025 01:26
@js-choi js-choi requested review from scottaohara and removed request for a team May 12, 2025 01:26
@github-actions github-actions bot added Content:Accessibility Accessibility docs size/xs [PR only] 0-5 LoC changed labels May 12, 2025
Copy link
Contributor

@scottaohara
Copy link
Contributor

scottaohara commented May 12, 2025

I’m not sure where the “If no level is present, a value of 2 is the default” claim comes from.

defaulting to a level of 2 is how the role was previously spec'd, and it is what browsers are instructed to do to mitigate author error for not requiring a level.

see in section 9.2 States and Properties, the Fallback values for missing required attributes table. it's listed there that level 2 is the fallback value for an undefined aria-level on an element with a role of heading

@@ -27,7 +27,7 @@ This defines the text in the `<div>` to be the main heading of the page, indicat
### Associated WAI-ARIA roles, states, and properties

- [`aria-level`](/en-US/docs/Web/Accessibility/ARIA/Reference/Attributes/aria-level)
- : The `aria-level` attribute specifies the heading level in the document structure. If no level is present, a value of 2 is the default.
- : The `aria-level` attribute specifies the heading level in the document structure. This attribute is required: authors must indicate the proper nesting level, to ensure elements with a role of heading are organized into a logical outline.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- : The `aria-level` attribute specifies the heading level in the document structure. This attribute is required: authors must indicate the proper nesting level, to ensure elements with a role of heading are organized into a logical outline.
- : The `aria-level` attribute specifies the heading level in the document structure. This attribute is required: authors must indicate the proper nesting level to ensure elements with a `role` of `heading` are organized into a logical outline.

@js-choi
Copy link
Contributor Author

js-choi commented May 15, 2025

Thanks for the explanation, @scottohara. I will update the pull request with an explanation that, if the required attribute is not specified, then a fallback value of 2 will be specified.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content:Accessibility Accessibility docs size/xs [PR only] 0-5 LoC changed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants